<template>
	<view class="box">
		
		<!-- <view class="search_box">

          <u-search :show-action="false" placeholder="搜索感兴趣文章" @search='to' v-model="params.title"></u-search>
		  
		  <view class="tab_box">
			  	  <u-tabs :list="cate" :bold="true" :is-scroll="false" :current="current" @change="change"></u-tabs>		  
		  </view>
	
		</view> -->
		
		<view class="list_box">
			
			<view class="info_box" v-for="(item,index) in list" :key="index" @click="$project.toPath('/pages/news/mannersdetail?id='+item.id)">
				<image mode="widthFix"  class="img" :src="item.image"></image>
				<view class="title">{{item.title}}</view>
				<!-- <view class="c_box">
					<view class="b_box">
						<view>{{item.time}}</view>
						<view>阅读 {{item.look}}</view>
					</view>
				</view> -->
				
			</view>
			
		</view>
		
		<view class="bitmap" v-if="emptyShow">
			<image src="../../static/img/no_content.png" mode="aspectFit"></image>
			<view class="gray_font fs-13">
				暂无
			</view>
		</view>
		
		
	</view>
</template>

<script>
	
	export default{
		data(){
			return{
				keyword:'',
				cate:[],
				current:0,
				params:{page:1,limit:10,cate_id:0,title:'',type:2},
				list:[],
				total:0,
				emptyShow:false
				
			}
		},
		onShow() {
			
		},
		onLoad() {
		
		this.getCate();
		this.getList();
		   	
		},
		methods:{
			to(){
				this.getList();
			},
			change(e){
				console.log(e);
				this.current=e;
				this.params.cate_id=this.cate[e].id;
				this.getList();
			},
			
			getCate(){
				this.$get(this.$api.cateList,{type:2},res=>{
					// console.log(res,"cateList")
					let {code,data} = res.data;
					
					if(code==1&&data.length>0){
						data.unshift({id:0,name:'全部'});
						this.cate=data;
					}
					
				});
			},
			getList() {
				this.params.page = 1;
				this.params.type = 3;
				this.$get(this.$api.newsList, this.params, res => {
					console.log(res)
					let data = res.data;
			
					if (!data.data.data || data.data.data.length < 1) {
						this.emptyShow = true;
					} else {
						this.emptyShow = false;
					}
			
					this.list = data.data.data;
					this.total = data.data.total;
				});
			}
		},
		onReachBottom() {
			if (this.list.length < this.total) {
				this.params.page++;
				this.$get(this.$api.newsList, this.params, res => {
					// console.log(res)
					let data = res.data;
					data.data.data.forEach(ress => {
						this.list.push(ress);
					});
				});
			}
		},
	}
</script>

<style lang="scss" scoped>
	/deep/ .u-tab-item{
		background-color: transparent !important;
		font-size: 28rpx !important;
	}
	.box{
		min-height: 100vh;
		background-color: #F6F6F6;
		box-sizing: border-box;
		padding: 0 20rpx;
	}
	.search_box{
		background-color: white;
		box-sizing: border-box;
		padding: 20rpx 20rpx 5rpx 20rpx;
	}
	.tab_box{
		margin-top: 20rpx;
	}
	.list_box{
		box-sizing: border-box;
		padding: 20rpx 15rpx;
	}
	.info_box{
		border-radius: 15rpx;
		background-color: white;
		margin-bottom: 35rpx;
		box-sizing: border-box;
		padding: 0rpx 0 20rpx 0;
	}
	.img{
		width: 100%;
		height: 300rpx;
		border-top-left-radius: 15rpx;
		border-top-right-radius: 15rpx;
		vertical-align: bottom;
		margin-bottom: 20rpx;
		
	}
	.c_box{
		width: 57%;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}
	.title{
		font-weight: bold;
		text-align: center;
	}
	.b_box{
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 26rpx;
		color: #978E8C;
	}
	.bitmap {
		margin-top: 10vh;
		text-align: center;
	}
</style>